package com.example.blogsystem_ssm.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Bean
    public BCryptPasswordEncoder getBCryptPasswordEncoder(){
        return  new BCryptPasswordEncoder();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new BlogSystemInterceptor())
                .addPathPatterns("/**")// 拦截 所有的 url
                .excludePathPatterns("/login")// 登录功能不拦截。不登录，哪来的信息给我们验证？
                .excludePathPatterns("/bloglogin.html")//登录页面不用拦截
                .excludePathPatterns("/css/**.css")
                .excludePathPatterns("/js/**.js")
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/fronts/**")
                .excludePathPatterns("/editor.md/**");
    }
}

